<template>
	<view>
		<!-- 吸顶 view -->
		<view class="fixed-top-view" id="fixed-top-view">
			<view class="graceSelectMenuItem" style="display: flex;width: 90%;margin: auto;">
				<view :class="lc_is == 0 ? 'lc_view lc_this' : 'lc_view'">
					<view :class="lc_is == 0 ? 'yuan gui-bg-red' : 'yuan'">1</view>
					<view class="wenzi">确认报备</view>
				</view>
				<view :class="lc_is == 1 ? 'lc_view lc_this' : 'lc_view'">
					<view :class="lc_is == 1 ? 'yuan gui-bg-red' : 'yuan'">2</view>
					<view class="wenzi">上传附件</view>
				</view>
				<view :class="lc_is == 2 ? 'lc_view lc_this' : 'lc_view'">
					<view :class="lc_is == 2 ? 'yuan gui-bg-red' : 'yuan'">3</view>
					<view class="wenzi">等待审核</view>
				</view>
				<view :class="lc_is == 10 ? 'lc_view lc_this' : 'lc_view'">
					<view :class="lc_is == 10 ? 'yuan gui-bg-red' : 'yuan'">4</view>
					<view class="wenzi">查看结果</view>
				</view>
			</view>
		</view>

		<!-- 页面主体 加一个与吸顶元素等高的 margin-top 或 padding-top -->
		<view class="gui-margin" style="margin-top:40rpx; margin-bottom: 30rpx;">

			<!-- 完善信息 -->
			<view v-if="lc_is == 0" class="main_view" style="">
				<form @submit="submit">
					<view class="gui-form-item gui-border-b" style="height: 100rpx;">
						<text class="gui-form-label">申请项目 :</text>
						<view class="gui-form-body">
							<text style="font-size: 36rpx;" class="gui-color-blue">{{cate_name}}</text>
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">申请原因 :</text>
						<view class="gui-form-body">
							<view class="graceSelectMenuItem" style="width: 100%;">
								<gui-select-menu :items="s_category" @select="select_category" :selectIndex="s_index"
									ref="s2"></gui-select-menu>
							</view>
						</view>
					</view>

					<view v-if="is_category.length > 0" v-for="(item,index) in is_category"
						class="gui-form-item gui-border-b" :key='index' style="padding-left: 60rpx;">
						<text class="gui-form-label">{{item.name}}</text>
						<view class="gui-form-body">
							<input :adjust-position="true" v-model="formData.category_data[item.note]"
								:placeholder="'请输入'+item.name" v-if="item.type == 'input'" type="text" value=""
								class="gui-form-input" style="border: #acacac solid 1rpx;" />

							<view v-if='item.type == "select"' class="gui-margin-top">
								<picker mode="selector" :range="item.data" @change="pickerChange">
									<view class="gui-flex gui-rows gui-nowrap gui-space-between gui-align-items-center">
										<text class="gui-text">{{item.data[genderIndex]}}</text>
										<text
											class="gui-form-icon gui-icons gui-text-center gui-color-gray">&#xe603;</text>
									</view>
								</picker>
							</view>
							<!-- <view v-if="item.type == 'select'" class="graceSelectMenuItem">
								<gui-select-menu :items="s_category" @select="select_category" ref="s2"></gui-select-menu>
							</view> -->
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">在职状态 :</text>
						<view class="gui-form-body">
							<view class="graceSelectMenuItem">
								<!-- <gui-select-menu :items="s_works" @select="select_work" ref="selectMenu1"></gui-select-menu> -->
								<input :adjust-position="true" disabled v-model="formData.work_status" value=""
									type="text" class="gui-form-input" name="work_status" placeholder="无在职状态" />
							</view>
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">填报时间 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.time" value="" type="text"
								class="gui-form-input" name="time" placeholder="填报时间" />
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">厂牌号 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.user_bh" value="111" type="text"
								class="gui-form-input" name="user_bh" placeholder="厂牌号" />
						</view>
					</view>
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">所在单位 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.lessee" value="111" type="text"
								class="gui-form-input" name="lessee" placeholder="所在单位" />
						</view>
					</view>
					<!-- <view class="gui-form-item gui-border-b">
						<text class="gui-form-label">所在部门 :</text>
						<view class="gui-form-body gui-bg-gray">
							<input :adjust-position="true" disabled v-model="formData.dept" value="111" type="text" class="gui-form-input" name="dept" placeholder="所在部门" />
						</view>
					</view> -->
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">会员姓名 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.name" value="" type="text"
								class="gui-form-input" name="name" placeholder="会员姓名" />
						</view>
					</view>
					<!-- <view class="gui-form-item gui-border-b">
						<text class="gui-form-label">身份证号 :</text>
						<view class="gui-form-body gui-bg-gray">
							<input :adjust-position="true" disabled v-model="formData.sfz" value="" type="text" class="gui-form-input"
								name="sfz" placeholder="身份证号" />
						</view>
					</view> -->
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">性别 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.sex" value="" type="text"
								class="gui-form-input" name="sex" placeholder="性别" />
						</view>
					</view>
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">本人电话 :</text>
						<view class="gui-form-body">
							<input :adjust-position="true" disabled v-model="formData.self_phone" value="" type="text"
								class="gui-form-input" name="self_phone" placeholder="本人电话" />
						</view>
					</view>

					<view v-for="(item,init_index) in form_init" :key='init_index' class="gui-form-item gui-border-b">

						<text
							:class="item.name == '是否柳州市城区内住院' ? 'gui-form-label1' : (item.name == '是否进行了入院慰问' ? 'gui-form-label2' : 'gui-form-label')">{{item.name}}:</text>

						<view class="gui-form-body" v-if="item.name == '账户开户行'">
							<input :adjust-position="true" v-if="item.type == 'input'"
								v-model="formData.form_data[item.note]" value="" type="text" class="gui-form-input"
								:name="item.note" :placeholder="'如：中国农业银行柳州分行'" />
							<textarea v-if="item.type == 'textarea'" v-model="formData.form_data[item.note]"
								:name="item.note" value="" :placeholder="'如：中国农业银行柳州分行'"
								class="gui-textarea gui-border-box gui-border-radius" style="" />
						</view>

						<view class="gui-form-body" v-else-if="item.name == '是否柳州市城区内住院'">
							<uni-data-checkbox v-model="radio" :localdata="inHospital"
								@change="hospitalChange"></uni-data-checkbox>
						</view>

						<view class="gui-form-body" v-else-if="item.name == '是否进行了入院慰问'">
							<uni-data-checkbox v-model="radio2" :localdata="hospitalObservation"
								@change="hospitalObservationChange"></uni-data-checkbox>
						</view>

						<view class="gui-form-body" v-else-if="item.name == '享受补助总金额'">
							<input :adjust-position="true" v-if="item.type == 'input'"
								v-model="formData.form_data[item.note]" value="" type="text" class="gui-form-input"
								:name="item.note" :placeholder="item.name + '(若没有, 请填无)'" />
							<textarea v-if="item.type == 'textarea'" v-model="formData.form_data[item.note]"
								:name="item.note" value="" :placeholder="'如：中国农业银行柳州分行'"
								class="gui-textarea gui-border-box gui-border-radius" style="" />
						</view>

						<view class="gui-form-body" v-else-if="item.name == '卡种'">
							<!-- formData.form_data[item.note] -->
							<input :adjust-position="true" v-if="item.type == 'input'"
								v-model="formData.form_data[item.note]" value="" type="text" class="gui-form-input"
								:name="item.note" :placeholder="'请输入储蓄卡'" />
						</view>

						<view class="gui-form-body" v-else-if="item.note.includes('time')">
							<view
								style="width: 100%; display: flex; align-items: center; justify-content: space-between;">
								<picker mode="date" :value="date" :start="startDate" :end="endDate"
									@change="bindDateChange">
									<view :class="date == '点我选择' ? 'shijian1' : 'shijian2'">{{date}}</view>
								</picker>
								<view v-if="formData.form_data[item.note]" class="xiugai">(点击日期可进行修改)</view>
							</view>
						</view>

						<view class="gui-form-body" v-else>
							<input :adjust-position="true" v-if="item.type == 'input'"
								v-model="formData.form_data[item.note]" value="" type="text" class="gui-form-input"
								:name="item.note" :placeholder="'请输入' + item.name" />
							<textarea v-if="item.type == 'textarea'" v-model="formData.form_data[item.note]"
								:name="item.note" value="" :placeholder="'请输入' + item.name"
								class="gui-textarea gui-border-box gui-border-radius" style="" />
						</view>
					</view>
				</form>
			</view>

			<!-- 上传附件 -->
			<view v-if="lc_is == 1" class="main_view">
				<view class="gui-margin-top" style="padding-top: 20rpx;">
					<button type="primary" style="font-size: 32rpx;" @tap="lc_is = 0">修改信息</button>
				</view>
				
				
				<!-- <cl-upload v-model="item.list_img"
					action="https://jf.lgwisdomunion.cn/api/public/upload_aliyun_oss_video"
					@onSuccess="onSuccess($event,index)" :imageFormData='imageFormData'
					:videoFromData='videoFromData'></cl-upload> -->
					
					
				<view v-for="(item,index) in category_file_set" class="gui-margin-top gui-bg-gray" :key="index"
					style="padding-bottom: 20rpx;">
					<view class="gui-margin-top-large" style="margin: 10rpx 0; padding-top: 10rpx;">
						<text class="gui-text" style="font-size: 32rpx;">{{item.name}}</text>
						<text class="gui-text gui-color-gray" style="font-size: 30rpx;">{{item.note}}</text>
					</view>
					<view class="">
						<button class="gui-bg-green gui-color-white" style="font-size: 32rpx;"
							@tap="upload_img(item,index)">添加</button>
					</view>
					<view
						class="gui-idcard-items gui-img-in gui-flex gui-rows gui-justify-content-center gui-margin-top">
						<view class="gui-idcard-items-image" v-for="(img_item,img_index) in show_file_img[index]"
							:key="img_index" style="margin: 0 10rpx;">
							<view class="" @click="show_img(img_item)">
								<gui-image
									:src="img_item ? img_item : 'https://img-cdn-tc.dcloud.net.cn/uploads/article/20210107/e53bf48607dcf795ab78e419dc5cf432.png'"
									:width="120"></gui-image>
							</view>
							<view class="gui-margin-top" style="">
								<button @click.stop="dele_file_img(index,img_index)" class="gui-bg-red"
									style="font-size: 28rpx;">删除</button>
							</view>
							<!-- <gui-image v-else src="https://img-cdn-tc.dcloud.net.cn/uploads/article/20210107/e53bf48607dcf795ab78e419dc5cf432.png" :width="380"></gui-image> -->
						</view>
					</view>
				</view>
				<!-- <view style="margin-top:50rpx;">
					<button type="default" class="gui-button gui-bg-blue" 
					style="border-radius:80rpx;" 
					@tap="uploadCards">
						<text class="gui-icons gui-color-white gui-button-text">&#xe642; 上传</text>
					</button>
				</view> -->
				<!-- <view class="gui-margin-top" style="padding-top: 20rpx;">
					<text class="gui-h4 gui-color-red">* 本人确认上传的资料真实有效,并签名 : </text>
					<button class="gui-bg-yellow" type="primary" @tap="show_member_qm">签名</button>
					<image :src="formData.qm" mode="widthFix"></image>
				</view> -->
				<view style="display: flex; margin-top: 50rpx;" @click="ok_click">
					<view
						style="border-radius: 50%; border: 1px solid #017AFF; width: 42rpx; height: 42rpx; margin-top: 5rpx;">
						<view v-if="whether == true"
							style="background-color: #017AFF; border-radius: 50%; width: 30rpx; height: 30rpx; margin: 6rpx">
						</view>
					</view>
					<view style="font-size: 35rpx; width: 90%; margin-left: 15rpx;">
						<text style="color: red; margin-right: 5rpx;">*</text>本人提交材料真实有效，如有不实自行承担相关责任。选择后请确认审核序列。
					</view>
				</view>
				<view style="height: 50rpx;"></view>
			</view>

			<!-- 等待审核:isInput="true" inputType="search"  -->
			<view v-if="lc_is == 2 && is_approvers.length == 0" class="main_view">
				<view v-for="(item,index) in select_length" class="gui-form-item gui-border-b" :key="index">
					<text class="gui-form-label">审核人{{index + 1}}</text>
					<view class="gui-form-body">
						<view class="graceSelectMenuItem" style="width: 100%;text-align: center;">
							<!-- <gui-select-menu
							:selectIndex="item - 1"
							:items="selectMenu4" 
							@select="select4" 
							@is_select="select_id(index)"
							ref="selectMenu3" style="width: 100%;"></gui-select-menu> -->
							<!-- <picker v-if="defult_approvers[index]" @change="picker_select" @click="picker_index = index" :value="index" :range="selectMenu4"><view class="uni-input">{{defult_approvers[index].name}}</view></picker> -->
							<text>{{defult_approvers[index] ? defult_approvers[index].name : '无'}}</text>
						</view>
					</view>
				</view>
			</view>

			<view v-if="lc_is == 2 && is_approvers.length > 0" class="main_view">
				<view v-for="(item,index) in is_approvers" class="gui-form-item gui-border-b" :key="index">
					<text class="gui-form-label">{{item.approver_name}}</text>
					<view class="gui-form-body">
						<view v-if="item.approver_status == 1" class="">
							<text class="gui-color-green">已审核</text>
							<text>审核意见 : {{item.approver_opinion}}</text>
						</view>
						<view v-else class="">
							<text v-if="item.is_approver == 1" class="gui-color-blue">正在审核</text>
							<text v-else>待审核</text>
						</view>
					</view>
				</view>
			</view>

			<!-- 查看结果 -->
			<view v-if="lc_is == 10" class="main_view">
				<text
					style="display: block;width: 100%;text-align: center;font-size: 48rpx;margin-top: 20rpx; padding-top: 20rpx;">审核流程</text>
				<view v-if="!is_approvers.length" class="gui-text-center gui-color-gray">
					<text>无 审批流</text>
				</view>
				<view v-for="(item,index) in is_approvers" class="gui-border-b gui-margin-top" :key="'ok'+index">
					<text class="" style="margin: 20rpx 0;">{{item.approver_name}}</text>
					<view class="gui-form-body" style="width: 100%;margin-top: 10rpx;">
						<view v-if="item.approver_status == 1" class="">
							<view class="" v-if="item.is_approver == 1">
								<text class="gui-color-red">审核不通过</text>
								<text style="margin-left: 10rpx;">审核意见 : {{item.approver_opinion.split("|")[0]}}</text>
							</view>
							<view class="" v-else>
								<text class="gui-color-green">已审核</text>
								<text style="margin-left: 10rpx;">审核意见 : {{item.approver_opinion.split("|")[0]}}</text>
							</view>
						</view>
						<view v-else class="">
							<text v-if="item.is_approver == 1" class="gui-color-blue">正在审核</text>
							<text v-else>待审核</text>
						</view>
					</view>
				</view>

				<view v-if="hzj_apply.status == 10" class="" style="width: 100%;padding-bottom: 30rpx;">
					<text class="gui-form-label" style="font-size: 32rpx;width: 100%;">下载地址 : </text>
					<view class="" style="width: 100%;">
						<input :adjust-position="true" type="text" :value="file_path" class="gui-form-input"
							style="border: #007AFF solid 2rpx;width: 90%;margin: auto;height: 60rpx;" />
					</view>
					<text class="gui-form-label gui-color-red" style="font-size: 32rpx;width: 100%;">注 :
						请复制下载地址到浏览器进行下载!</text>
					<button @tap="upload_apply" type="default" class="gui-button gui-gtbg-blue gui-noborder"
						style="width: 90%;margin: auto;">
						<text class="gui-color-white gui-button-text">上传最终申请单</text>
					</button>
				</view>
				<view v-else-if="hzj_apply.status == 2"
					style="width: 100%;height: 100rpx;text-align: center; border-bottom: 1rpx solid black; margin-top: 22rpx;">
					<text class="gui-form-label gui-color-red" style="font-size: 35rpx;width: 100%;">审核状态: 审核中...</text>
				</view>
				<view v-else class="" style="width: 100%;height: 200rpx;">
					<text class="gui-form-label gui-color-red"
						style="font-size: 32rpx;width: 100%;text-align: center;">审核未通过</text>
					<button v-if="hzj_apply.status != 9" class="gui-bg-green gui-color-white"
						@tap="lc_is = 0;back = 1;">返回修改</button>
				</view>

				<view class="">
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">申请项目 :</text>
						<view class="gui-form-body">
							<text style="font-size: 36rpx;" class="gui-color-blue">{{cate_name}}</text>
						</view>
					</view>
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">申请原因 :</text>
						<view class="gui-form-body">
							<view class="graceSelectMenuItem" style="width: 100%;">
								<text style="font-size: 36rpx;"
									class="gui-color-blue">{{hzj_apply.category_name}}</text>
							</view>
						</view>
					</view>

					<view v-if="is_category.length > 0" v-for="(item,index) in is_category"
						class="gui-form-item gui-border-b" :key='"ok_a"+index' style="padding-left: 60rpx;">
						<text class="gui-form-label">{{item.name}}</text>
						<view class="gui-form-body">
							<!-- <input :adjust-position="true" v-model="formData.category_data[item.note]" :placeholder="'请输入'+item.name" v-if="item.type == 'input'" type="text" value="" class="gui-form-input" style="border: #acacac solid 1rpx;" /> -->
							<text class="gui-form-input"
								style="">{{hzj_apply.category_data.split(",")[index].split("=")[1]}}</text>

							<!-- <view v-if='item.type == "select"' class="gui-margin-top">
								<picker mode="selector" :range="item.data" @change="pickerChange">
									<view class="gui-flex gui-rows gui-nowrap gui-space-between gui-align-items-center">
										<text class="gui-text">{{item.data[genderIndex]}}</text>
										<text class="gui-form-icon gui-icons gui-text-center gui-color-gray">&#xe603;</text>
									</view>
								</picker>
							</view> -->
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">在职状态 :</text>
						<view class="gui-form-body">
							<view class="graceSelectMenuItem">
								<text style="" class="gui-form-input">{{hzj_apply.work_status}}</text>
							</view>
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">填报时间 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.created_at}}</text>
						</view>
					</view>

					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">厂牌号 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.user_bh}}</text>
						</view>
					</view>
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">所在单位 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.lessee}}</text>
						</view>
					</view>
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">会员姓名 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.member}}</text>
						</view>
					</view>
					<!-- <view class="gui-form-item gui-border-b">
						<text class="gui-form-label">身份证号 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.sfz}}</text>
						</view>
					</view> -->
					<view class="gui-form-item gui-border-b">
						<text class="gui-form-label">性别 :</text>
						<view class="gui-form-body gui-bg-gray">
							<text style="" class="gui-form-input">{{hzj_apply.sex}}</text>
						</view>
					</view>

					<view v-for="(item,init_index) in form_init" class="gui-form-item gui-border-b"
						:key='"ok_i"+init_index'>
						<text :class="item.name == '是否柳州市城区内住院' ? 'gui-form-label1' : (item.name == '是否进行了入院慰问' ? 'gui-form-label2' : 'gui-form-label')">{{item.name}}
							:</text>
						<view class="gui-form-body gui-bg-gray">
							<text v-if="item.type == 'input'"
								class="gui-form-input">{{formData.form_data[item.note]}}</text>
							<textarea disabled v-if="item.type == 'textarea'" value="formData.form_data[item.note]"
								:placeholder="'请输入' + item.name" class="gui-textarea gui-border-box gui-border-radius"
								style="" />
						</view>
					</view>
				</view>

				<!-- <view class="gui-margin-top gui-border-b gui-bg-gray" style="padding-bottom: 20rpx;">
					<view class="gui-margin-top-large">
						<text class="gui-text gui-h4">本人签名 : </text>
					</view>
					<view
						class="gui-idcard-items gui-img-in gui-flex gui-rows gui-justify-content-center gui-margin-top">
						<view class="gui-idcard-items-image" style="margin: 0 10rpx;">
							<view class="" @click="show_img(hzj_apply.member_qm)">
								<gui-image :src="hzj_apply.member_qm" :width="200"></gui-image>
							</view>
						</view>
					</view>
				</view> -->
				<view v-for="(item,index) in hzj_apply.file" class="gui-margin-top gui-border-b gui-bg-gray"
					:key="'ok_f'+index" style="padding-bottom: 20rpx;">
					<view class="gui-margin-top-large" v-if="item.category_file">
						<text class="gui-text gui-h4">{{item.category_file.name}}</text>
						<text class="gui-text gui-color-gray">{{item.category_file.note}}</text>
					</view>
					<view
						class="gui-idcard-items gui-img-in gui-flex gui-rows gui-justify-content-center gui-margin-top">
						<view class="gui-idcard-items-image" v-for="(img_item,img_index) in item.path.split(',')"
							:key="'ok_img'+img_index" style="margin: 0 10rpx;">
							<view class="" @click="show_img(img_item)">
								<gui-image
									:src="img_item ? img_item : 'https://img-cdn-tc.dcloud.net.cn/uploads/article/20210107/e53bf48607dcf795ab78e419dc5cf432.png'"
									:width="200"></gui-image>
							</view>
						</view>
					</view>
				</view>
				<view v-if="!category_file_set.length" class="gui-text-center gui-margin-top gui-color-gray"
					style="padding-bottom: 20rpx;">
					<text>无 附件信息</text>
				</view>
			</view>

			<!-- <text class="gui-block-text gui-text gui-text-center gui-color-gray" 
			style="margin-top:100rpx;">...页面主体开始，请滚动页面测试...</text>
			<view style="height:2000px;"></view> -->

			<!-- 居中弹出 -->
			<gui-popup ref="guipopup1">
				<view class="gui-relative gui-box-shadow gui-bg-white" style="padding: 20rpx;">
					<!-- <gui-image src="https://cmsuse.oss-cn-beijing.aliyuncs.com/g5/16.png" :width="580"></gui-image> -->
					<text class="gui-text gui-color-red gui-h6" style="">注 : 请在下方区块手写签名或<button
							class="gui-bg-red gui-color-white" @tap="show_big">{{big_tip}}</button></text>

					<view v-if="is_big" class="gui-margin-top gui-bg-gray">
						<image :src="formData.qm" mode="widthFix"></image>
					</view>
					<view v-else class="gui-margin-top gui-bg-gray"
						:style="{height:canvas.height+'rpx', overflow:'hidden'}">
						<canvas id="graceSign" canvas-id="graceSign" @touchstart="tstart" @touchmove="tmove"
							:style="{width:canvas.width+'rpx', height:canvas.height+'rpx'}"></canvas>
					</view>
					<view class="gui-margin-top gui-flex gui-rows gui-space-between" v-if="!isNew">
						<text class="sign-btn gui-text gui-color-gray gui-block-text" @tap="canvasInit">重新签名</text>
						<text class="sign-btn gui-text gui-color-blue gui-block-text" @tap="upload_qm">提交签名</text>
					</view>

					<view class="gui-margin-top gui-text-center" v-if="tip_text">
						<text class="gui-color-red">{{tip_text}}</text>
					</view>

					<!-- 关闭按钮 -->
					<text class="gui-block-text demo-close gui-icons gui-color-white gui-absolute-rt"
						@tap.stop="close1">&#xe78a;</text>
				</view>
			</gui-popup>

			<!-- 居中弹出 -->
			<gui-popup ref="guipopup2" :width="'100%'">
				<view class="gui-relative gui-box-shadow gui-bg-white" style="padding: 20rpx;height: 1200rpx;">
					<!-- <gui-image src="https://cmsuse.oss-cn-beijing.aliyuncs.com/g5/16.png" :width="580"></gui-image> -->
					<text class="gui-text gui-color-red gui-h6" style="">注 :
						请横屏书写,提交上传上传之后会自动处理,上传完成后点击确认签名即可看到效果</text>

					<view class="gui-margin-top gui-bg-gray" :style="{height:'900rpx', overflow:'hidden'}">
						<canvas id="graceSign2" canvas-id="graceSign2" @touchstart="tstart" @touchmove="tmove"
							:style="{width:canvas.width+'rpx', height:'900rpx'}"></canvas>
					</view>
					<view class="gui-margin-top gui-flex gui-rows gui-space-between" v-if="!isNew2">
						<text class="sign-btn gui-text gui-color-gray gui-block-text" @tap="canvasInit">重新签名</text>
						<text class="sign-btn gui-text gui-color-blue gui-block-text" @tap="upload_qm">提交签名</text>
					</view>

					<view class="gui-margin-top gui-text-center" v-if="tip_text">
						<text class="gui-color-red">{{tip_text}}</text>
					</view>

					<!-- 关闭按钮 -->
					<text class="gui-block-text demo-close gui-icons gui-color-white gui-absolute-rt"
						@tap.stop="close2">&#xe78a;</text>
				</view>
			</gui-popup>

			<view class=""><!-- 遮盖层 -->
				<gui-page-loading ref="guipageloading"></gui-page-loading>
			</view>
		</view>

		<view class="gui-flex gui-rows gui-space-between gui-align-items-center"
			style="border-top:1px solid #E8E8E8;z-index: 1;">
			<view class="" style="margin-top: 15rpx;width: 92%; margin: 0 auto; margin-bottom: 40rpx;">
				<button v-if="lc_is == 0" @tap="to_next()" type="default" class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">确认报备</text>
				</button>
				<button v-if="lc_is == 1" @tap="up_file_arr" type="default" class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">确认申请</text>
				</button>
				<button v-if="lc_is == 2 && is_approvers.length == 0" @tap="approvers" type="default"
					class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">确认提交审核</text>
				</button>
				<button v-if="lc_is == 2 && is_approvers.length > 0" @tap="tip('0','请耐心等待审核结果')" type="default"
					class="gui-button gui-gtbg-blue gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">审核中</text>
				</button>
				<button v-if="hzj_apply.status == 9" @tap="to_back()" type="default"
					class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">重新申报</text>
				</button>
				<button v-if="lc_is == 10 && hzj_apply.status == 10" @tap='generate' type="default"
					class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text v-if="file_path" class="gui-color-white gui-button-text">重新生成</text>
					<text v-else class="gui-color-white gui-button-text">生成文档</text>
				</button>
				<button v-if="lc_is == 10 && hzj_apply.status == 0" @tap="lc_is = 0;back = 1;" type="default"
					class="gui-button gui-gtbg-red gui-noborder"
					style="width: 100%;margin: auto; border-radius: 20rpx;">
					<text class="gui-color-white gui-button-text">返回修改</text>
				</button>
				<!-- <view @tap="to_next()" class="gui-footer-large-button gui-text-center gui-bg-red" style="width: 90%;margin: auto;border-radius: 50%;" hover-class="gui-tap">
					<text class="gui-icons" style="margin-right: 10rpx;">&#xe614;</text>
					<text class="gui-text gui-footer-large-button-text">下一步</text>
				</view> -->
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				radio: -1,
				radio2: -1, // 新增：hospital_observation的单选值
				inHospital: [{
					text: '是',
					value: 0
				}, {
					text: '否',
					value: 1
				}],
				hospitalObservation: [{ // 新增：hospital_observation的选项数据
					text: '是',
					value: 0
				}, {
					text: '否',
					value: 1
				}],
				p_index: -1,
				presents: [{
					value: 0,
					text: '200元+鸡蛋+牛奶'
				}],
				canIn: false,
				canObserve: false, // 新增：hospital_observation的控制变量
				name: '',
				category_id: '',
				apply_id: null,
				s_works: ['在岗', '内退(内病退)', '离岗'],
				s_category: [], //下拉数组
				s_index: 0, //所选下标
				category_row: [], //对应数据
				apiLoadSta: true,
				formData: {
					category_data: {},
					form_data: {},
					qm: ''
				},
				user: [],
				lc_is: 0,
				selectMenu4: ['无审批人'],
				selectIndex4: [],
				select_index: 0, //下拉选择器下标
				approver_index: [], //提交审批流
				select_length: 3, //下拉数量
				hzj_apply: [],
				is_approvers: [],
				file_path: null,
				category: 1, //当前所选类目(大)
				cate_name: '会员慰问',
				is_category: [],
				genderIndex: 0,

				category_file_set: [], //分类所需附件
				file_img: [],
				//用于h5回显或是加key重载组件
				show_file_img: {
					'0': '',
					'1': '',
					'2': '',
					'3': '',
					'4': '',
					'5': '',
					'6': '',
					'7': '',
					'8': '',
				}, //用于展示
				form_init: [], //表单配置
				defult_approvers_ids: [], //默认审核序列,纯id
				defult_approvers: [], //默认审核序列
				picker_index: 0,

				//是否大屏
				is_big: false,
				ctx2: null, // 画布对象,
				drawTimer2: null, // 演示存储计算器,
				isNew2: true, // 画布是否是空白的

				//签名
				canvas: {
					width: 690, // 画布宽度，单位 rpx
					height: 380, // 画布高度, 单位 rpx
					bgColor: '#F6F7F8', // 画布演示
					textColor: '#000000', // 画笔颜色
					widthIn: 300, // 自动计算转换为 px
					heightIn: 300, // 自动计算转换为 px
					size: 3, // 画笔粗细
				},
				ctx: null, // 画布对象,
				drawTimer: null, // 演示存储计算器,
				isNew: true, // 画布是否是空白的

				qm_img: '', //签名base64
				tip_text: '', //提交提示文本
				big_tip: '使用大屏',
				chuxuka: '储蓄卡',
				whether: false,

				date: '点我选择',
				radio: -1,
			}
		},
		onLoad: function(option) {
			this.name = option.name
			this.category_id = option.category_id
			this.category = option.category;
			this.cate_name = option.cate_name;
			this.apply_id = option.apply_id;
			// console.log('apply: ', this.apply_id);

			this.user = uni.getStorageSync("member");
			if (!this.user) {
				uni.reLaunch({
					url: "../login/login"
				});
			}
		},
		onReady: function() {
			let date = new Date();
			this.formData.name = this.user.name;
			this.formData.uuid = this.user.uuid;
			this.formData.sex = this.user.sex;
			this.formData.work_status = this.user.state;
			this.formData.user_bh = this.user.lg_id;
			this.formData.work_status = this.s_works[0];
			this.formData.self_phone = this.user.phone;
			if (this.user.lessee) {
				this.formData.lessee = this.user.organization;
			} else {
				this.formData.lessee = '默认单位';
			}
			this.formData.time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
			uni.showLoading({
				title: '加载中'
			});
			this.get_apply();
			this.canvasInit();
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods: {
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			bindDateChange: function(e) {
				let self = this
				let form_init = self.form_init
				for (var i = 0; i < form_init.length; i++) {
					if (form_init[i].note.includes('time')) {
						self.formData.form_data[form_init[i].note] = e.detail.value
					}
				}
				self.date = e.detail.value
			},
			ok_click() {
				this.whether = !this.whether
			},
			to_back() {
				let self = this;
				uni.navigateTo({
					url: './apply?category=' + self.category + '&cate_name=' + self.cate_name
				});
			},
			show_big() { //显示大屏
				this.open2();
				this.is_big = true;
				this.big_tip = "重新生成";
				this.canvasInit();
			},
			upload_qm() { //上传签名
				let self = this;
				if (this.qm_img) {
					let is_rotate = 0;
					if (self.is_big) { //大屏旋转处理
						is_rotate = 1;
					}
					self.$refs.guipageloading.open();
					let url = '/public/localhost_up_base64'
					let parm = {
						pathName: self.user.id + self.user.name + '.png',
						tmppath: this.qm_img,
						file: this.qm_img,
						is_rotate: is_rotate
					}
					self.$boya.NPost(url, parm, function(res) {
						self.$refs.guipageloading.close();
						if (res.code == 200) {
							self.tip_text = "签名上传成功";
							self.formData.qm = res.data.url;
							self.close1();
							if (self.is_big) {
								self.close2();
							}
						} else {
							self.tip_text = "签名上传失败,请重试";
						}
						console.log(res, 'upload');
					})
				} else {
					self.tip_text = "未签名";
				}
			},
			tstart: function(e) {
				var x = e.touches[0].x;
				var y = e.touches[0].y;
				if (this.is_big) {
					this.ctx2.moveTo(x, y);
					this.isNew2 = false;
				} else {
					this.ctx.moveTo(x, y);
					this.isNew = false;
				}
			},
			tmove: function(e) {
				var x = e.touches[0].x;
				var y = e.touches[0].y;
				if (this.is_big) {
					this.ctx2.lineTo(x, y);
					this.ctx2.stroke();
					this.ctx2.draw(true, this.saveImg2);
					this.ctx2.moveTo(x, y);
				} else {
					this.ctx.lineTo(x, y);
					this.ctx.stroke();
					this.ctx.draw(true, this.saveImg);
					this.ctx.moveTo(x, y);
				}
			},
			// 手写完毕后自动生成一个临时图片文件
			saveImg: function() {
				let self = this;
				if (this.drawTimer != null) {
					clearTimeout(this.drawTimer);
				}
				this.drawTimer = setTimeout(() => {
					uni.canvasToTempFilePath({
						x: 0,
						y: 0,
						width: this.widthIn,
						height: this.heightIn,
						destWidth: this.widthIn,
						destHeight: this.heightIn,
						canvasId: 'graceSign',
						success: (res) => {
							// 在H5平台下，tempFilePath 为 base64
							console.log(res.tempFilePath);
							self.qm_img = res.tempFilePath;
						}
					});
				}, 200);
			},
			saveImg2: function() {
				let self = this;
				if (this.drawTimer2 != null) {
					clearTimeout(this.drawTimer2);
				}
				this.drawTimer2 = setTimeout(() => {
					uni.canvasToTempFilePath({
						x: 0,
						y: 0,
						width: this.widthIn,
						height: this.heightIn,
						destWidth: this.widthIn,
						destHeight: this.heightIn,
						canvasId: 'graceSign2',
						success: (res) => {
							// 在H5平台下，tempFilePath 为 base64
							console.log(res.tempFilePath);
							self.qm_img = res.tempFilePath;
						}
					});
				}, 200);
			},
			//签名版初始化
			canvasInit: function() {
				setTimeout(() => {
					this.ctx = uni.createCanvasContext('graceSign');
					this.canvas.widthIn = uni.upx2px(this.canvas.width);
					this.canvas.heightIn = uni.upx2px(this.canvas.height);
					this.ctx.setFillStyle(this.canvas.bgColor);
					this.ctx.fillRect(0, 0, this.canvas.widthIn, this.canvas.heightIn);
					this.ctx.draw(true);
					this.ctx.setStrokeStyle(this.canvas.textColor);
					this.ctx.setLineWidth(this.canvas.size);
					this.isNew = true;
				}, 500);

				setTimeout(() => {
					this.ctx2 = uni.createCanvasContext('graceSign2');
					this.canvas.widthIn = uni.upx2px(this.canvas.width);
					this.canvas.heightIn = uni.upx2px(this.canvas.height);
					this.ctx2.setFillStyle(this.canvas.bgColor);
					this.ctx2.fillRect(0, 0, this.canvas.widthIn, 900);
					this.ctx2.draw(true);
					// this.ctx2.rotate(45 * Math.PI/180);
					this.ctx2.setStrokeStyle(this.canvas.textColor);
					this.ctx2.setLineWidth(this.canvas.size);
					this.isNew2 = true;
				}, 500);
			},
			dele_file_img(index, img_index) { //删除
				console.log(index, 'index');
				console.log(img_index, 'img_index');
				console.log(this.show_file_img);
				console.log(this.file_img);
				this.show_file_img[index].splice(img_index, 1);
				this.file_img[index].url.splice(img_index, 1);
			},
			show_img(url) {
				uni.previewImage({
					urls: [url],
					index: 0
				});
			},
			picker_select(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				// this.index = e.detail.value;
				// this.defult_approvers[this.picker_index] = this.selectMenu4[e.detail.value];
				this.defult_approvers[this.picker_index].name = this.selectMenu4[e.detail.value];
				this.approver_index[this.picker_index] = this.selectIndex4[e.detail.value];
				console.log(this.approver_index, 'approver_index');
			},
			// selectImg1 : function() {
			// 	uni.chooseImage({
			// 		count:1,
			// 		success:(res) => {
			// 			this.idCard1 = res.tempFilePaths[0];
			// 			console.log(res.tempFilePaths[0],'res.tempFilePaths[0]');
			// 		}
			// 	})
			// },
			upload_apply(item, index) {
				let self = this;
				// uni.uploadFile
				uni.chooseImage({
					count: 1,
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.uploadFile({
							url: self.apiUrl + "/hzj_apply/res_upload_apply",
							filePath: tempFilePaths[0],
							name: 'file',
							formData: {
								'apply_id': self.apply_id,
								'member_id': self.user.id,
								'member': self.user.name,
							},
							success: (up_res) => {
								let upload_res = JSON.parse(up_res.data);
								if (upload_res.code == 200) {
									self.tip('1', '上传成功!');
								} else {
									self.tip('0', '上传失败!');
								}
								console.log(upload_res, 'up_res');
							}
						});
					}
				});
			},
			upload_img(item, index) {
				if (this.show_file_img[index].length > 4) {
					this.tip('0', '每个分类最多仅允许上传 五 张');
					return;
				}

				let self = this;
				// uni.uploadFile
				uni.chooseImage({
					count: 1,
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.uploadFile({
							url: self.apiUrl + "/hzj_apply/upload_huaweicloud_obs",
							filePath: tempFilePaths[0],
							name: 'file',
							// formData:{
							// },
							success: (up_res) => {
								let upload_res = JSON.parse(up_res.data);
								if (upload_res.code == 200) {
									self.tip('1', '上传成功!');
									self.file_img[index].id = item.id;
									self.file_img[index].name = item.name;
									self.file_img[index].url.push(upload_res.data.url); //push数据泄露
									// self.file_img[index].url[self.file_img[index].url.length] = upload_res.data.url;
									self.show_file_img[index].push(upload_res.data.url); //push数据泄露
									// self.show_file_img[index][self.show_file_img[index].length] = upload_res.data.url;
									// console.log(self.file_img,'file_img');
									// console.log(self.show_file_img,'show_file_img');
								} else {
									self.tip('0', '上传失败!');
								}
								// self.file_img[id] = upload_res.url;
								console.log(self.file_img[index], 'self.show_file_img[index]');
								console.log(upload_res, 'up_res');
							}
						});
					}
				});
			},
			// picker 切换
			pickerChange: function(e) {
				console.log(e);
				this.genderIndex = e.detail.value;
				this.formData.category_data[this.is_category[0].note] = this.is_category[0].data[this.genderIndex];
			},
			hospitalChange(e) {
				let self = this
				if (e.detail.data.text == '是') {
					self.canIn = true
				} else {
					self.canIn = false
					self.p_index = -1
					self.formData.form_data.scheme = null
				}
				self.formData.form_data.whether_location = e.detail.data.text
				console.log('hhhhhhhhhh: ', self.formData.form_data);
			},
			hospitalObservationChange(e) {
				let self = this
				if (e.detail.data.text == '是') {
					self.canObserve = true
				} else {
					self.canObserve = false
				}
				self.formData.form_data.hospital_observation = e.detail.data.text
				console.log('hospital_observation: ', self.formData.form_data);
			},
			sendPresents(e) {
				let self = this
				self.formData.form_data.scheme = e.detail.data.text
				console.log('hhhhhhhhhh: ', self.formData.form_data);
			},
			select_work(index, val) { //选择在职状态
				this.formData.work_status = val;
				console.log("选择了 " + index + val);
			},
			select_category(index, val) { //选择申请分类1
				var self = this
				let cate = this.category_row[index];
				console.log(index, 'index');
				console.log(val, 'val');
				// console.log(cate, 'cate');

				this.s_index = index;
				this.formData.category_id = cate.id;
				this.formData.category_name = cate.name;
				this.formData.category_data = [];

				// debugger;
				if (cate.type == 'this') {
					this.formData.category_data[cate.note] = cate.name;
				} else {
					this.is_category = cate.cate;
					if (cate.cate[0].type == 'select') { //默认值和设置
						this.is_category[0].data = this.is_category[0].data.split(',');
						this.formData.category_data[this.is_category[0].note] = this.is_category[0].data[this.genderIndex];
					}
				}
			},

			select_id(index) { //获取当前动态数量的select的下标
				this.select_index = index;
				console.log(index, '当前selecct_index');
			},
			select4: function(index, val) {
				// console.log("选择了 " + index + val);
				console.log(this.selectIndex4[index], this.select_index + "selct选择了");
				this.approver_index[this.select_index] = this.selectIndex4[index]; //审批流数组
				console.log(this.approver_index, 'this.approver_index');
			},
			select1: function(index, val) {
				5
				// 获得选择项目后按照数据继续排序即可
				console.log("选择了 " + val);
				this.orderIndex = 0;
				this.orderByIndex = 0;
			},

			submit(e) {
				console.log(e.detail.value);
				let input_data = e.detail.value;
			},
			to_next() {
				let self = this;
				uni.showLoading({
					title: '正在确认信息...'
				});
				let check_res = self.check(self.formData);
				if (check_res == '1') {
					let url = '/hzj_apply/create_apply'
					let parm = {
						input_data: this.formData,
						apply_id: this.apply_id
					}
					self.$boya.NPost(url, parm, function(res) {
						console.log('create: ', res);
						if (res.code == 200) {
							if (self.apply_id) {
								self.tip('1', '更新成功');
							} else {
								self.tip('1', '创建成功');
								self.apply_id = res.data.id;
							}
							self.get_apply();
						} else {
							self.tip('0', res.data);
						}
						uni.hideLoading();
					})
				} else {
					uni.showToast({
						title: check_res,
						icon: 'error'
					});
				}
			},
			check(data) {
				// console.log('data: ', data);
				// console.log('category_data: ', data.category_data);
				// console.log('form_data: ', data.form_data);
				// item.data.replace(/,/g, '，')
				let self = this;
				let category_data = data.category_data
				let form_data = data.form_data
				Object.keys(category_data).forEach(function(key) {
					let value = category_data[key];
					if (typeof value == 'string') {
						let change = value.replace(/,/g, '，');
						category_data[key] = change;
					}
					// console.log('category_data[key]: ', category_data[key]);
				});
				Object.keys(form_data).forEach(function(key) {
					let value = form_data[key];
					if (typeof value == 'string') {
						let change = value.replace(/,/g, '，');
						form_data[key] = change;
					}
					// console.log('form_data[key]: ', form_data[key]);
				});
				let is = '0';
				if (data) {
					if (self.name == '会员结婚' || self.formData.category_name == '会员结婚') {
						data.category_data = {
							type: '会员结婚'
						}
					}
					let c_data = data.category_data;
					if (typeof c_data != 'string') {
						c_data = Object.assign({}, c_data);
						c_data = JSON.stringify(c_data);
						if (c_data == '{}') {
							c_data = 0;
						} else {
							self.formData.category_data = Object.assign({}, self.formData.category_data);
						}
					}

					let form_init = self.form_init
					for (let i = 0; i < form_init.length; i++) {
						if (form_init[i].name.includes('时间')) {
							// console.log('data: ', data.form_data[form_init[i].note]);
							// 获取用户输入的日期
							let marriageDate = data.form_data[form_init[i].note];
							// 获取当前日期
							let currentDate = new Date();
							// 将用户输入的日期转为日期对象
							let marriageDateObj = new Date(marriageDate);
							// 计算日期差（以天数为单位）
							let timeDifference = currentDate - marriageDateObj; // 返回毫秒数
							let daysDifference = timeDifference / (1000 * 3600 * 24); // 转换为天数
							console.log('天数: ', daysDifference);
							// 判断是否超过183天
							if (daysDifference < 0) {
								// 提示用户不能进行申请
								uni.showToast({
									title: '注意，不可填写未来的时间',
									duration: 3000,
									icon: 'none'
								});
								return is = 0
							} else if (daysDifference > 183) {
								uni.showToast({
									title: '已超出183天申请时间范围，不能进行申请',
									duration: 3000,
									icon: 'none'
								});
								return is = 0
							}
						}
						// console.log('这里这里form_init[i]: ', form_init[i]);
						if (self.canIn == false) {
							if (form_init[i].is_required) { //是否必填
								if (!data.form_data[form_init[i].note]) {
									is = "无 " + form_init[i].name;
									return is;
								}
							}
						}
						if (self.canObserve == false) {
							if (form_init[i].is_required) { //是否必填
								if (!data.form_data[form_init[i].note]) {
									is = "无 " + form_init[i].name;
									return is;
								}
							}
						}
					}

					if (!data.category_id) {
						is = "未选择申请分类";
					} else if (!c_data) {
						is = "未输入申请分类所需数据";
					} else if (!data.user_bh) {
						is = "无厂牌号!";
					} else if (!data.lessee) {
						is = "无所在单位!";
					} else if (!data.name) {
						is = "未输入姓名!";
					}
					//  else if (!data.sfz) {
					// 	is = "无身份证!";
					// }
					else if (!data.sex) {
						is = "无性别!";
						// }else if(!data.form_data.address){
						// 	is = "无家庭住址!";
						// }else if(!data.form_data.sfz){
						// 	is = "未输入手机号!";
					} else {
						is = 1;
					}
				} else {
					is = "无数据";
				}
				return is;
			},
			get_apply() {
				let self = this;
				if (self.user) {
					// this.apiLoadSta = true;
					self.$refs.guipageloading.open();
					let url = '/hzj_apply/get_apply'
					let parm = {
						user_id: self.user.id,
						apply_id: self.apply_id,
						c_id: self.category
					}
					self.$boya.NPost(url, parm, function(res) {
						console.log('get: ', res);
						uni.hideLoading();
						// self.apiLoadSta = false;
						if (res.data == '您还有未完成的申请单') {
							console.log('走到这里2');
							// uni.showToast({icon:'error',title:res.data});
							uni.showModal({
								title: '提示',
								content: res.data,
								showCancel: false,
								success() {
									uni.redirectTo({
										url: '/pages/activities/apply/index/my_apply'
									})
									// uni.navigateBack();
								}
							})
						} else {
							self.get_category();
							if (res.msg == 'not') { //不是未找到,只是没有,即新申请
							} else {
								console.log('数据: ', res.data);
								self.hzj_apply = res.data; //申请单

								// let shuju = res.data.file
								// for (var i = 0; i < shuju.length; i++) {
								// 	console.log('这里这里: ', shuju[i].category_file);
								// }
								self.formData.form_data = JSON.parse(res.data.form_data);
								// console.log('self.formData.form_data: ', self.formData.form_data);
								// console.log('res.data.status: ', res.data.status);
								// || res.data.status == '2'
								if (res.data.status == '0' || res.data.status == '9') {
									self.lc_is = 10; //申请单状态
								} else {
									self.lc_is = res.data.status; //申请单状态
								}
								if (self.formData.form_data.whether_location == '是') {
									self.radio = 0
									self.canIn = true
									self.p_index = 0
								} else if (self.formData.form_data.whether_location == '否') {
									self.radio = 1
								}
								if (self.formData.form_data.hospital_observation == '是') {
									self.radio2 = 0
									self.canObserve = true
								} else if (self.formData.form_data.hospital_observation == '否') {
									self.radio2 = 1
								}
								self.is_approvers = res.data.process; //审批流
								self.file_path = res.data.apply_file; //生成文档
								// self.get_category_file();
								if (self.lc_is == 1) {
									self.get_category_file();
									// self.get_approvers();
								} else if (self.lc_is == 2) {
									self.get_approvers();
								}
							}
						}
						self.$refs.guipageloading.close();
					})
				} else {
					uni.showToast({
						icon: 'error',
						title: "无用户信息!!"
					});
				}
			},
			get_category() { //获取分类
				let self = this;
				let url = '/hzj_apply/get_category'
				let parm = {
					c_id: self.category
				}
				self.$boya.NPost(url, parm, function(res) {
					if (res.code == 200) {
						console.log('cate：', res);
						self.category_row = ['无']; //初始值
						self.s_category = ['请选择']; //初始值
						self.select_length = res.data.limit;
						self.defult_approvers_ids = res.data.defult_approvers; //默认审核序列(纯id)

						for (let i = 0; i < res.data.cate.length; i++) {
							if (self.category_id) {
								if (self.category_id == res.data.cate[i].id) {
									console.log('shuju1: ', res.data.cate[i]);
									self.category_row.push(res.data.cate[i]);
									self.s_category.push(res.data.cate[i].name);
								}
							} else {
								self.category_row.push(res.data.cate[i]);
								self.s_category.push(res.data.cate[i].name);
							}

							if (self.apply_id && res.data.cate[i].id == self.hzj_apply
								.category_id) { //其他阶段返回修改

								// console.log('这里self.apply_id: ', self.apply_id);
								// console.log('这里res.data.cate[i].id: ', res.data.cate[i].id);
								// console.log('这里self.hzj_apply.category_id: ', self.hzj_apply.category_id);

								self.s_index = i + 1; //+1是因为有一个默认值"请选择"

								self.formData.category_id = res.data.cate[i].id;
								self.formData.category_name = res.data.cate[i].name;
								self.formData.category_data = [];
								// debugger;
								if (res.data.cate[i].type && res.data.cate[i].type == 'this') {
									self.formData.category_data[res.data.cate[i].note] = res.data.cate[i]
										.name;
								} else {
									// console.log('is_category: ', res.data.cate[i].cate);
									self.is_category = res.data.cate[i].cate;
									if (res.data.cate[i].cate[0] && res.data.cate[i].cate[0].type ==
										'select') { //默认值和设置
										self.is_category[0].data = self.is_category[0].data.split(',');
										self.formData.category_data[self.is_category[0].note] = self
											.is_category[0]
											.data[self.genderIndex];
									}
								}
							}
							// console.log("self.formData：", self.formData);
						}
						// console.log("self.formData：", self.formData);

						// console.log('s_category: ', self.s_category);
						// console.log('self.formData.category_name: ', self.formData.category_name);
						// console.log('res.data.form_init: ', res.data.form_init);
						// console.log('self.formData.category_name: ', self.formData.category_name);
						if (!self.formData.category_name) {
							if (self.s_category[1] == '会员生育' || self.s_category[1] == '直系亲属去世' || self.s_category[
									1] == '会员结婚') {
								res.data.form_init.splice(3, 2)
								// 过滤掉"是否进行了入院慰问"字段
								res.data.form_init = res.data.form_init.filter(item => item.name !== '是否进行了入院慰问')
								// 找到时间字段并修改为对应的时间名称
								for (let i = 0; i < res.data.form_init.length; i++) {
									if (res.data.form_init[i].note === 'time') {
										if (self.s_category[1] == '会员生育') {
											res.data.form_init[i].name = '新生儿出生时间'
										} else if (self.s_category[1] == '直系亲属去世') {
											res.data.form_init[i].name = '亲属去世时间'
										} else if (self.s_category[1] == '会员结婚') {
											res.data.form_init[i].name = '结婚时间'
										}
										break
									}
								}
							} else if (self.s_category[1] == '会员住院') {
								// 找到时间字段并修改为出院时间
								for (let i = 0; i < res.data.form_init.length; i++) {
									if (res.data.form_init[i].note === 'time') {
										res.data.form_init[i].name = '出院时间'
										break
									}
								}
							}
						} else if (self.formData.category_name == '会员生育' || self.formData.category_name ==
							'直系亲属去世' || self.formData.category_name == '会员结婚') {
							res.data.form_init.splice(3, 2)
							// 过滤掉"是否进行了入院慰问"字段
							res.data.form_init = res.data.form_init.filter(item => item.name !== '是否进行了入院慰问')
							// 找到时间字段并修改为对应的时间名称
							for (let i = 0; i < res.data.form_init.length; i++) {
								if (res.data.form_init[i].note === 'time') {
									if (self.formData.category_name == '会员生育') {
										res.data.form_init[i].name = '新生儿出生时间'
									} else if (self.formData.category_name == '直系亲属去世') {
										res.data.form_init[i].name = '亲属去世时间'
									} else if (self.formData.category_name == '会员结婚') {
										res.data.form_init[i].name = '结婚时间'
									}
									break
								}
							}
						} else if (self.formData.category_name == '会员住院') {
							// 找到时间字段并修改为出院时间
							for (let i = 0; i < res.data.form_init.length; i++) {
								if (res.data.form_init[i].note === 'time') {
									res.data.form_init[i].name = '出院时间'
									break
								}
							}
						}
						self.form_init = res.data.form_init;
						// console.log('form_init: ', self.form_init);
					} else {
						self.tip('0', res.data);
					}
					uni.hideLoading();
					// self.s_category = res.data;
				})
			},
			get_approvers() { //获取审批人
				let self = this;
				self.$refs.guipageloading.open();
				let url = '/hzj_apply/get_approvers'
				let parm = {
					defult_approvers: self.defult_approvers_ids,
					cate: self.category
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log('获取审批人: ', res);
					self.$refs.guipageloading.close();
					if (res.code == 200) {
						self.selectMenu4 = [];
						self.selectIndex4 = res.data.all_data;
						for (let i = 0; i < res.data.all_data.length; i++) {
							self.selectMenu4.push(res.data.all_data[i].name);
						}

						self.defult_approvers = res.data.defult_approvers; //默认审核数据,全部

						self.approver_index = [];
						for (let j = 0; j < res.data.defult_approvers.length; j++) { //生成默认审批流,用于提交和渲染的
							self.approver_index.push(res.data.defult_approvers[j]);
						}
						// console.log(self.defult_approvers,'默认');
					} else {
						uni.showToast({
							icon: 'error',
							title: res.data
						});
					}
					uni.hideLoading();
				})
			},
			approvers() { //确认审核序列
				let self = this;
				console.log('self.hzj_apply: ', self.hzj_apply);
				console.log('self.approver_index: ', self.approver_index);
				// return;
				self.$refs.guipageloading.open();
				let url = '/hzj_apply/approval_process'
				let parm = {
					apply: self.hzj_apply,
					approver_process: self.approver_index
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log(res, 'post');
					self.$refs.guipageloading.close();
					if (res.code == 200) {
						self.tip('1', '操作成功!!');
						self.get_apply();
					} else {
						self.tip('0', res.data);
					}
				})
			},
			generate() { //生成文档
				let self = this;
				this.$refs.guipageloading.open();
				let url = '/hzj_apply/generate'
				let parm = {
					apply: self.hzj_apply
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log(res, 'generate');
					self.$refs.guipageloading.close();
					if (res.code == 200) {
						self.file_path = res.data;
						self.tip('1', '生成成功');
					} else {
						self.tip('0', res.data);
					}
				})
			},
			get_category_file() { //获取分类所需附件
				let self = this;
				let url = '/hzj_apply/get_category_file'
				let parm = {
					c_id: self.hzj_apply.category_id
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log('get_category_file: ', res);
					if (res.code == 200) {
						if (res.data.length == '0') {
							self.skip_up_file();
						} else {
							self.category_file_set = res.data; //所需上传附件
							console.log('所需上传附件：', res);
							for (let i = 0; i < res.data.length; i++) { //初始化处理
								if (self.hzj_apply.file.length) {
									let path_arr = self.hzj_apply.file[i].path.split(",");
									self.show_file_img[i] = path_arr;
									self.file_img[i] = {
										id: self.hzj_apply.file[i].category_file_id,
										name: self.hzj_apply.file[i].name,
										url: path_arr
									};
								} else {
									self.file_img[i] = {
										id: '',
										name: '',
										url: []
									};
									self.show_file_img[i] = [];
								}
							}
						}
						// self.$refs.guipageloading.close();
					} else {
						self.tip('0', res.data);
					}
					uni.hideLoading();
				})
			},
			skip_up_file() { //跳过上传附件
				let self = this;
				self.$refs.guipageloading.open();
				let url = '/hzj_apply/skip_up_file'
				let parm = {
					user: self.user,
					a_id: self.hzj_apply.id
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log(res, 'skip_up_file');
					self.$refs.guipageloading.close();
					if (res.code == 200) {
						self.get_apply();
					} else {
						self.tip('0', res.data);
					}
				})
			},
			//01 居中弹出
			open1: function() {
				this.$refs.guipopup1.open();
			},
			close1: function() {
				this.$refs.guipopup1.close();
			},
			//全屏签名
			open2: function() {
				this.$refs.guipopup2.open();
			},
			close2: function() {
				this.$refs.guipopup2.close();
			},
			show_member_qm() {
				this.open1();
			},
			up_file_arr() { // 确认上传附件 ＋ 确认审核序列
				let self = this;
				console.log(self.file_img, 'up_file_img');
				let error_text = [];
				for (let i = 0; i < self.file_img.length; i++) {
					if (self.file_img[i].url.length == 0) {
						error_text.push(self.category_file_set[i].name);
					}
				}
				if (error_text.length) {
					uni.showModal({
						title: '提示',
						content: error_text.join("===") + "未上传文件"
					});
					return;
				}

				if (self.whether == false) {
					uni.showModal({
						title: '提示',
						content: '请勾选: 材料上传承诺'
					});
					return;
				}

				this.$refs.guipageloading.open();
				let up_file_img = self.file_img;
				up_file_img = Object.assign({}, up_file_img); //数组合并转object,php问题,无法获取

				let url = '/hzj_apply/up_file_arr'
				let parm = {
					file_img: up_file_img,
					user: self.user,
					a_id: self.hzj_apply.id,
					qm: 'null'
				}
				self.$boya.NPost(url, parm, function(res) {
					console.log(res, 'up_file_arr');
					self.$refs.guipageloading.close();
					if (res.code == 200) {
						// self.approvers();
						self.get_apply();
					} else {
						self.tip('0', res.data);
					}
				})
			},
			tip(is, text) {
				if (is == 1) {
					uni.showToast({
						icon: 'success',
						title: text
					});
				} else if (is == 2) {
					uni.showToast({
						icon: 'loading',
						title: text
					});
				} else {
					uni.showToast({
						icon: 'error',
						title: text
					});
				}
			}
		}
	}
</script>
<style>
	.gui-form-label {
		width: 150rpx;
	}

	.gui-form-label1 {
		font-size: 28rpx;
		width: 290rpx;
		height: 100rpx;
		line-height: 100rpx;
	}

	.gui-form-label2 {
		font-size: 28rpx;
		width: 350rpx;
		height: 100rpx;
		line-height: 100rpx;
	}

	page {
		background-color: #e6e6e6;
	}

	/* 自定义吸顶元素样式 */
	.fixed-top-view {
		padding: 20rpx 0;
		background-color: #ffffff;
		margin: 40rpx 20rpx 0 20rpx;
		border-radius: 20rpx;
	}

	.graceSelectMenuItem {
		width: 180rpx;
	}

	.right-area {
		flex: 1;
		height: 800rpx;
	}

	.colorTags {
		width: 120rpx;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		font-size: 26rpx;
		color: #FFFFFF;
		border-radius: 5rpx;
	}

	.price-input {
		width: 120rpx;
		padding: 15rpx;
		line-height: 50rpx;
		height: 80rpx;
		font-size: 26rpx;
		text-align: center;
		background-color: #F5F6F8;
		border-radius: 5rpx;
	}

	.right-area-footer {
		width: 580rpx;
		height: 100rpx;
		background-color: #F7F8FA;
	}

	.right-area-footer-btn {
		width: 290rpx;
		height: 100rpx;
		line-height: 100rpx;
		font-size: 28rpx;
		text-align: center;
	}

	.lc_view {
		width: 25%;
		margin: 0;
		text-align: center;
	}

	.lc_this {
		color: red;
	}

	.yuan {
		border-radius: 50%;
		background-color: #acacac;
		width: 60rpx;
		height: 60rpx;
		text-align: center;
		line-height: 65rpx;
		margin: auto;
		color: #fff;
	}

	.wenzi {
		font-size: 28rpx;
		margin-top: 5rpx;
	}

	.main_view {
		margin: auto;
		background-color: #fff;
		margin-top: 30rpx;
		border-radius: 20rpx;
		padding: 0 20rpx;
	}

	.gui-form-input {
		padding-left: 20rpx;
	}

	.shijian1 {
		font-size: 28rpx;
		border: 3rpx solid black;
		border-radius: 6rpx;
		padding: 5rpx;
		box-shadow: 5rpx 10rpx 10rpx rgba(0, 0, 0, 0.4);
		margin-left: 22rpx;
		background-color: rgba(230, 230, 230, 0.6);
	}

	.shijian2 {
		font-size: 31rpx;
		margin-left: 22rpx;
	}

	.xiugai {
		font-size: 25rpx;
	}

	/* .gui-form-label{width: 160rpx;height: 100rpx;line-height: 100rpx;overflow: hidden;} */
</style>